<?php
include "config.php";
if ($_SERVER["REQUEST_METHOD"]=="POST") {
    if (isset($_REQUEST["uname"]) && isset($_REQUEST["upwd"])) {

        $uname = $_REQUEST["uname"];
        $upwd = $_REQUEST["upwd"];
        //4.准备sql语句
        $sql = "  SELECT * FROM user2 WHERE uname='" . $uname . "' AND upwd='" . $upwd . "'";

        //5.执行sql语句

        $result = $conn->query($sql);

        //6.判断结果
        $reuslt = $conn->query($sql);
        $arr = array("msg" => "登录失败,请检查你的用户名或密码是否正确", "status" => -1, "data" => "");
        if ($reuslt->num_rows >= 1) {
            $arr["msg"] = "登录成功";
            $arr["status"] = "1";
            $arr["data"] = $reuslt->fetch_assoc();
        }

        print_r(json_encode($arr));


        $conn->close();

    }
}